<template>
    <div class="detail_module_panel loan_history">
        <h3 id="work_student" class="detail_panel_title detail_panel_title_icon other_info_icon">{{$t('common.historicalInfo')}}</h3>
        <div class="panel_info_content">
            <el-table class="loan_history_table" :data="tableData" style="width: 100%">
                <el-table-column align="left" :label="$t('common.serialNumber')" min-width="80"><!--序号-->
                    <template slot-scope="scope">{{ scope.$index + 1 }}</template>
                </el-table-column>
                <el-table-column align="left" prop="contractAmount" :label="$t('common.borrowAmount')">
                    <template slot-scope="{ row }">{{ row.contractAmount | formatCurrency }}</template>
                </el-table-column><!--借款金额-->
                <el-table-column align="left" prop="loanPeriod" :label="$t('common.borrowingCycle')" min-width="80"></el-table-column><!--借款周期-->
                <el-table-column align="left" :label="$t('common.applyDate')" min-width="120"><!--申请时间-->
                    <template slot-scope="scope">{{ scope.row.borrowTime | formatDate('yyyy-MM-dd hh:mm:ss') }}</template>
                </el-table-column>
                <el-table-column align="left" prop="orderId" :label="$t('common.innerOrderId')" min-width="160">
                    <template slot-scope="{ row }">
                        <a @click="goDetail(row)" type="text" size="small" href="javascript:void(0);">{{ row.orderId }}</a>
                    </template> 
                </el-table-column><!--内部订单号-->
                <el-table-column align="left" :label="$t('system.appName')" prop="appName" min-width="90"></el-table-column><!--APP名称-->
                <el-table-column v-if="domain=='Bene'" :label="$t('finance.productName')" prop="whiteProductName" min-width="130"></el-table-column><!--伪名-->
                <el-table-column v-else align="left" :label="$t('finance.pseudonym')" prop="kana" min-width="90"></el-table-column><!--伪名-->

                <el-table-column align="left" prop="showStatus" :label="$t('common.orderStatus')">
                    <template slot-scope="scope">{{$root.local === 'zhCN' ? scope.row.showStatus : scope.row.showStatusIndo}}</template><!--订单状态-->
                </el-table-column>
                <el-table-column align="left" prop="firstJudgerName" :label="$t('audit.firstReviewer')" min-width="90"></el-table-column><!--初审员-->
                <el-table-column align="left" prop="finishedTime" :label="$t('audit.closeingTime')" min-width="120"><!--结案时间-->
                    <template slot-scope="scope">{{ scope.row.finishedTime | formatDate('yyyy-MM-dd hh:mm:ss') }}</template>
                </el-table-column>
                <el-table-column align="left" prop="refuseCode" :label="$t('audit.auditFailReason')" min-width="110"></el-table-column><!--信审失败原因-->
                <el-table-column align="left" prop="remark" :label="$t('common.remark')" min-width="110"></el-table-column><!--备注-->
            </el-table><!--end table-->
            <pagination @pageChange="pageChange" :page="page">分页组件</pagination>
        </div>
    </div>
</template>

<script>
    import mixin from '@/service/mixin';
    import Pagination from '@/components/pagination';

    export default {
        name: 'loanHistory',
        components: {
            Pagination
        },
        props: {
            userId: {
                default: ''
            }
        },
        mixins: [mixin],
        data() {
            return {
                domain:"",
                orderId: '',
                tableData: []
            };
        },
        methods: {
            getTableData(page) {
                const params = {
                    userId: this.userId,
                    orderId: this.orderId,
                    page: {
                        pageNo: page.currentPage,
                        pageSize: this.page.pageSize
                    },
                };
                this.$api.audit.getAllHistoryLoanList(params).then((res) => {
                    const {status, data, error} = res;
                    if ('1' === status && error === '00000000') {
                        this.tableData = data.data || [];
                        this.setPage(data.page, this.page);
                    }
                });
            },
            goDetail(row) {
                this.$storage.set('userId', row.userId);
                this.$storage.set('locale', this.$root.local);
                this.$openNewBlank(`#/conf/audit/order-manage/audit-detail/${row.userId}/${row.orderId}/false`);
            },
        },
        created() {
            this.domain = this.$storage.get('user').domain
            if (this.userId) {
                this.orderId = this.$route.params.orderId;
                this.getTableData({currentPage: this.page.currentPage});
            }
        }
    };
</script>

<style lang="scss" scoped>

</style>
